/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.skycode.conf.util;

import java.awt.BorderLayout;
import java.awt.Component;
import java.net.MalformedURLException;
import java.net.URL;
import javax.media.Manager;
import javax.media.MediaLocator;
import javax.media.Player;
import javax.swing.JFrame;
import javax.swing.JPanel;

/**
 *
 * @author LumiLatop
 */
public class Video extends JFrame{
    Player player;
    Component video;
    Component controles;
    
    public Video() {
        System.out.println("CONSTRUCTOR");
        setTitle("VIDEO DE PRUEBA");
        setSize(800, 600);
        setLocationRelativeTo(null);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setVisible(true);
        init();
    }
    
    private void init() {
        JPanel panel = new JPanel();
        panel.setLayout(new BorderLayout());
        
        URL url = null;
        try {
            url = new URL("file:///D:/Video.mpg");            
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
        
        try {
            player = Manager.createRealizedPlayer(new MediaLocator(url));
            video = player.getVisualComponent();
            video.setSize(800, 500);
            video.setVisible(true);
            if (video != null) {
                panel.add("Center", video);
            }
            controles = player.getControlPanelComponent();
            controles.setSize(800, 100);
            controles.setVisible(true);
            if (controles != null) {
                panel.add("South", controles);
            }
            add(panel);
            player.start();
            panel.updateUI();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
